package com.kdl.webconfig.vo;

import lombok.Data;

import java.io.Serializable;

/**
 * @author 王成杰
 * @description TODO
 * @date 2022-06-20 2:22 下午
 */

@Data
public class BaseRespVO<T> implements Serializable {

    private Integer code;

    private String msg;

    private T data;

    public static <T> BaseRespVO<T> success(T data) {
        BaseRespVO baseVO = new BaseRespVO();
        baseVO.setCode(0);
        baseVO.setMsg("success");
        baseVO.setData(data);
        return baseVO;
    }

    public static BaseRespVO fail(Integer errorCode, String errorMsg) {
        BaseRespVO baseVO = new BaseRespVO();
        baseVO.setCode(errorCode);
        baseVO.setMsg(errorMsg);
        return baseVO;
    }

    public static BaseRespVO fail(String errorMsg) {
        BaseRespVO baseVO = new BaseRespVO();
        baseVO.setCode(-1);
        baseVO.setMsg(errorMsg);
        return baseVO;
    }
}
